package com.java.utils;
import java.sql.*;
/**
 *
 *
 * 数据库连接工具类
 */
public class JdbcUtil {

    /**
     *
     *
     * Exception
     */
    public static Connection getConnection() throws Exception {

        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3307/javaweb","root", "123456");

        return connection;

    }

    /**
     * 2、释放资源
     */
    public static void release(ResultSet resultSet, Statement statement, Connection connection) {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (statement != null) {
            try {
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if (connection != null) {
            try {
                connection.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }


}
